//package com.filldream.fastboot.core.job;
//
//import cn.hutool.core.util.StrUtil;
//import com.alibaba.fastjson2.JSONObject;
//import com.filldream.fastboot.base.mapper.StockLastMapper;
//import com.filldream.fastboot.common.constant.enums.StockFstEnum;
//import com.filldream.fastboot.common.entity.db.StockLast;
//import com.filldream.fastboot.common.entity.db.StockOrder;
//import com.filldream.fastboot.common.okutil.stockV2.stock.StockInfo;
//import com.filldream.fastboot.common.okutil.stockV2.stock.StockUtil;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.ObjectUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.math.BigDecimal;
//import java.util.Collections;
//import java.util.LinkedList;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Slf4j
//@RestController
//@AllArgsConstructor
//public class SimulateAccountJob {
//
//
//    private final StockLastMapper stockLastMapper;
//
//    @Scheduled(cron = "0/1 * * * * ?")
//    public void autoGenSettOrder() {
//        List<StockOrder> list = stockLastMapper.getFilterStockList();
//        BigDecimal money = stockLastMapper.getMoney();
//        if(  ObjectUtils.isNotEmpty(list) ){
//            List<String> searchCodeList = list.stream().map(StockOrder::getSearchCode).collect(Collectors.toList());
//            String searchCodeStr = StrUtil.join(",", searchCodeList);
//            List<StockInfo> stockInfoList = StockUtil.getByCodes(searchCodeStr);
//        }
//    }
//
//    public static void deal(String searchCodeStr,BigDecimal money){
//        List<StockInfo> stockInfoList = StockUtil.getByCodes(searchCodeStr);
//        BigDecimal sumPrice = stockInfoList.stream()
//                .map(StockInfo::getNowPrice)  // 获取每个StockInfo的money字段
//                .filter(t -> t != null)  // 过滤掉null值
//                .reduce(BigDecimal.ZERO, BigDecimal::add);
//        BigDecimal avgPrice = sumPrice.divide(new BigDecimal(stockInfoList.size()), 2, BigDecimal.ROUND_HALF_UP);
//
//        //筛选出小于平均价格的股票
//        List<StockInfo> resultList = stockInfoList.stream()
//               .filter(stockInfo -> stockInfo.getNowPrice().compareTo(avgPrice) < 0).collect(Collectors.toList());
//
//        if(  ObjectUtils.isNotEmpty(resultList) ){
//            BigDecimal avgPrice2 = resultList.stream()
//                    .map(StockInfo::getNowPrice)
//                    .reduce(BigDecimal.ZERO, BigDecimal::add)
//                    .divide(new BigDecimal(resultList.size()), 2, BigDecimal.ROUND_DOWN);
//            System.out.println(avgPrice2);
//        }
//    }
//
//    public static void main(String[] args) {
//        deal("sh600889,sz002779,sh600793,sz002402,sh603516,sz003001,sz002856,sh603533",new BigDecimal("20000"));
//    }
//
//
//}
